<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../application/css/swiper.css">
    <script src="../application/vue.js"></script>
    <script src="../application/swiper.js"></script>
    <style>
        .div1 {
            width: 100%;
            height: 200px;
            background-color: chartreuse;
        }

        .div2 {
            width: 100%;
            height: 200px;
            background-color: rgb(25, 0, 255);
        }

        .div3 {
            width: 100%;
            height: 200px;
            background-color: rgb(223, 32, 96);
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- <div class="swiper-container" ref="loop">
            <div class="swiper-wrapper">
                <div class="div1 swiper-slide">slider1</div>
                <div class="div2 swiper-slide">slider2</div>
                <div class="div3 swiper-slide">slider3</div>
            </div>
        </div>
        <hr>
        <div class="swiper-container" ref="loop1">
            <div class="swiper-wrapper">
                <div class="div1 swiper-slide">slider1</div>
                <div class="div2 swiper-slide">slider2</div>
                <div class="div3 swiper-slide">slider3</div>
            </div>
        </div> -->
        <!-- <swiper-view></swiper-view>
        <swiper-view></swiper-view> -->
        <hr>
        <swiper-view>
            <div class="div1 swiper-slide">slider1</div>
            <div class="div2 swiper-slide">slider2</div>
            <div class="div3 swiper-slide">slider3</div>
        </swiper-view>
        <hr>
        <swiper-view :options="{autoplay:true}">
            <div class="div1 swiper-slide">slider1</div>
            <div class="div2 swiper-slide">slider2</div>
            <div class="div3 swiper-slide">slider3</div>
            <template v-slot:pagination>
                <div class="swiper-pagination">梦云</div>
            </template>
        </swiper-view>
    </div>
    <template id="child">
        <div class="swiper-container" ref="loop">
            <div class="swiper-wrapper">
                <slot></slot>
            </div>
            <slot name="pagination"></slot>
        </div>
    </template>
</body>
<script>
    Vue.component("swiperView",{
        template:"#child",
        props:{
            options:{
                type:Object,
                default(){
                    return{
                        autoplay:true,
                        pagination:{
                            el:".swiper-pagination"
                        }
                    }
                }
            }
        },
        mounted(){
            // console.log(this);
            // this.$nextTick(()=>{
            //     new Swiper(this.$refs.loop,{
            //         autoplay:true
            //     })
            // })
            this.$nextTick(()=>{
                new Swiper(this.$refs.loop,this.options)
            })
        }
    })
    new Vue({
        el: "#app",
        mounted() {
            // new Swiper(".swiper-container",{
            //     autoplay:true
            // })
            // console.log(this.$refs.loop);
            // new Swiper(this.$refs.loop,{
            //     autoplay:true
            // })
            this.$nextTick(() => {
                new Swiper(this.$refs.loop, {
                    autoplay: true
                })
            })
        }
    })
</script>

</html>